import re

# Greedy and non-greedy match

# greedy match
greedyRegex = re.compile(r'(la){3,5}')
mo = greedyRegex.search('lalalalala')
print(mo.group())
greedyRegex = re.compile(r'(la)?')
mo = greedyRegex.search('lalalalala')
print(mo.group())
# non-greedy match
greedyRegex = re.compile(r'(la){3,5}?')
mo = greedyRegex.search('lalalalala')
print(mo.group())
greedyRegex = re.compile(r'(la)*?')
mo = greedyRegex.search('lalalalala')
print(mo.group())
greedyRegex = re.compile(r'(la)+?')
mo = greedyRegex.search('lalalalala')
print(mo.group())
